package com.dao;

import com.entity.Projects;
import org.apache.ibatis.annotations.*;


import java.util.List;

/**
 * @Description: 项目dao  // 类说明，在创建类时要填写
 * @ClassName: ProjectsDao    // 类名，会自动填充
 * @Author: weisn          // 创建者
 * @Date: 2020/12/11 8:40   // 时间
 * @Version: 1.0     // 版本
 */
public interface ProjectsDao {
    /**
     * 查询所有项目
     * @return
     */
    @Select("select * from wenyu_xiangmu order by id asc limit #{begin},#{size}")
    public List<Projects> selectList(@Param("begin")int begin,@Param("size")int size);

    /**
     * 添加项目
     * @param projects
     * @return
     */
    @Insert("insert into wenyu_xiangmu(xmimg,xmbt,xmneirong,xmtime)"+"values(#{xmimg},#{xmbt},#{xmneirong},now())")
    @SelectKey(keyProperty = "id" , statement = "SELECT LAST_INSERT_ID()",before = false,resultType = Integer.class)
    boolean ProjectInsert(Projects projects);

    /**
     * 删除项目
     * @param id
     * @return
     */
    @Update("delete from wenyu_xiangmu where id=#{id}")
    boolean projectUpdate(int id);

    /**
     * 修改
     */
    @Update("update wenyu_xiangmu set xmimg=#{xmimg},xmbt=#{xmbt},xmneirong=#{xmneirong},xmtime=now() where id=#{id}")
    boolean update(Projects projects);

    /**
     * 自增重置
     */
    @Update("ALTER TABLE wenyu_xiangmu AUTO_INCREMENT = 1" )
    public boolean alter();

    /**
     * 通过id
     *
     */
    @Select("select * from wenyu_xiangmu where id=#{id}")
    public Projects selectId(int id);

    @Select("select count(1) from wenyu_xiangmu")
    public int selectCount();

}
